//
//  WYCDefaultCenterView.m
//  WYCweibo
//
//  Created by 魏云超 on 15/11/20.
//  Copyright © 2015年 魏云超. All rights reserved.
//

#import "WYCDefaultCenterView.h"
@interface WYCDefaultCenterView()
@property (weak, nonatomic) IBOutlet UIImageView *iconImageNamed;
@property (weak, nonatomic) IBOutlet UILabel *info;
@property (weak, nonatomic) IBOutlet UIImageView *iconRun;
@property (nonatomic, strong) CADisplayLink *link;
@property (weak, nonatomic) IBOutlet UIButton *loginBtn;
@property (weak, nonatomic) IBOutlet UIButton *regeBtn;


@end

@implementation WYCDefaultCenterView

+(instancetype)defaultCenterView
{
    return [[[NSBundle mainBundle]loadNibNamed:@"WYCDefaultCenterView" owner:nil options:nil] lastObject];
}
//注册
- (IBAction)regest:(id)sender {
    if ([self.delegate respondsToSelector:@selector(defaultCenterView:registButton:)]) {
        [self.delegate defaultCenterView:self registButton:sender];
    }
}
//登陆
- (IBAction)login:(id)sender {
    if ([self.delegate respondsToSelector:@selector(defaultCenterView:loginButton:)]) {
        [self.delegate defaultCenterView:self loginButton:sender];
    }
}
-(void)setIconName:(NSString *)iconName
{
    _iconName = iconName;
    self.iconImageNamed.image = [UIImage imageNamed:_iconName];
}
-(void)setInfoContent:(NSString *)infoContent
{
    _infoContent = infoContent;
    self.info.text = _infoContent;
}
-(void)startRun
{
    self.link.paused = NO;
}
-(void)endRun
{
    self.link.paused = YES;
//    [self.link invalidate];
//    self.link = nil;
}
#pragma lazy
-(CADisplayLink *)link
{
    if (!_link) {
        _link = [CADisplayLink displayLinkWithTarget:self selector:@selector(update)];
        [_link addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
    }
    return _link;
}
-(void)update
{
    self.iconRun.transform = CGAffineTransformRotate(self.iconRun.transform, M_PI / 100);
}
-(void)setShow:(BOOL)show
{
    _show = show;
    if (_show) {
        self.iconRun.hidden = NO;
    }
}

















@end
